﻿using System.Windows.Forms;

namespace ProgramMain.Framework
{
    public partial class frmBaseModal : DevExpress.XtraEditors.XtraForm
    {
        public frmBaseModal()
        {
            InitializeComponent();

            this.Icon = GlobalData.DefaultIcon();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        }
        
        public static DialogResult ShowModal(ProgramMain.Framework.BaseDetailCtl Ctl, string Caption, IButtonControl Accept, IButtonControl Cancel)
        {
            frmBaseModal frmCommon = new frmBaseModal();
            frmCommon.Controls.Add(Ctl);
            frmCommon.AutoSize = true;
            Ctl.Dock = DockStyle.Fill;
            frmCommon.StartPosition = FormStartPosition.CenterParent;

            frmCommon.Text = Caption;

            frmCommon.AcceptButton = Accept;
            frmCommon.CancelButton = Cancel;

            DialogResult res = frmCommon.ShowDialog(Program.MainForm);
            
            Program.MainForm.Activate();

            return res;
        }
    }
}